<?php
/**
* @package   auto_occasion
* @subpackage marqueModele
* @author    your name
* @copyright 2011 your name
* @link      http://www.yourwebsite.undefined
* @license    All rights reserved
*/

class BoModeleCtrl extends jController {

    public $pluginParams = array(
                                    '*'=>array('auth.required'=>true,
                                    'jacl2.right'=>'admin.compte.gerer'
                                    )
                            );

    /**
    *Fonction pour afficher les listes de marques 
    */
    function index() {

        jClasses::inc("marqueModele~marqueSrv");

        $toParams = array() ;
        $liste               = marqueSrv::getAllByOrder();
        $imarqueId = $this->intParam('iId') ; 
        $toParams['oMarque'] = ($imarqueId)?marqueSrv::getById($imarqueId): '' ;

        $rep = $this->getResponse('html');

        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/js/jquery.ui.core.js');
        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/js/jquery.ui.widget.js');
        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/js/jquery.ui.mouse.js');
        $rep->addJSLink($GLOBALS['gJConfig']->urlengine['basePath'].'design/back/js/jquery.ui.sortable.js');

        $rep->menusActifs = adminHtmlResponse::MENU_MARQUE_MODELE ;

        $rep->body->assign('liste',$liste);
        $rep->body->assign('marque',$toParams['oMarque']);
        $rep->body->assign('id',$imarqueId);

        $rep->bodyTpl = 'marqueModele~BoMarqueList';


        return $rep;
    }


    /**
    *Fonction pour réordonner les marques 
    */
    function reOrder() {
        
        jClasses::inc('marqueModele~modeleSrv') ;

        $postedParams = $this->params() ;

        $rep = $this->getResponse('text') ;
        $rep->content = modeleSrv::reOrder($postedParams) ;

        return $rep;
    }


   /**
     * sauvegarder une marque
     *
     *
     */
     function sauvegarder() {

        jClasses::inc("marqueModele~marqueSrv");
        jClasses::inc("marqueModele~modeleSrv");

        $toParams = $this->params() ;
        
        marqueSrv::store($toParams) ;
		modeleSrv::getModeleParams($toParams);
        
        $rep = $this->getResponse('redirect') ;
        $rep->action = 'marqueModele~BoMarque:index' ;

        return $rep;
    }

}

